<?php
use Hyperf\AsyncQueue\JobInterface;
if (!function_exists('queue_push')){
    /**
     * 投递到队列中
     * @param JobInterface $job [job类]
     * @param int $delay [延迟时间]
     * @param string $key [队列名]
     * @return bool
     */
    function queue_push(JobInterface $job,int $delay = 0,string $key='default') :bool{
        $driver = di()->get(\Hyperf\AsyncQueue\Driver\DriverFactory::class)
            ->get($key);
        return $driver->push($job,$delay);
    }
}


if (! function_exists('di')) {
    /**
     * 
     * Finds an entry of the container by its identifier and returns it.
     * @return mixed|\Psr\Container\ContainerInterface
     */
    function di(?string $id = null)
    {
        $container = \Hyperf\Utils\ApplicationContext::getContainer();
        if ($id) {
            return $container->get($id);
        }

        return $container;
    }
}